# 9 设计一个猜数字 游戏；最多只能猜测N次，在N次之内猜不出，就退出程序，提示猜测失败；

import random

def guess_number_game(max_attempts=8):
    number_to_guess = random.randint(1, 100)
    attempts = 0

    while attempts < max_attempts:
        guess = int(input("Guess the number (between 1 and 100): "))
        attempts += 1

        if guess < number_to_guess:
            print("Too low!")
        elif guess > number_to_guess:
            print("Too high!")
        else:
            print("Congratulations! You've guessed the number.")
            return

    print("Sorry, you've used all your attempts. The number was:", number_to_guess)

guess_number_game()